package com.t235.gc.device.service;

import com.t235.gc.dao.BsStreetDao;
import com.t235.gc.dao.RecyclersDao;
import com.t235.gc.dao.VenuesDao;
import com.t235.gc.entity.Recyclers;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class RecyclersService {

    @Resource
    private RecyclersDao recyclersDao;
    @Resource
    private BsStreetDao bsStreetDao;
    @Resource
    private VenuesDao venuesDao;

    public List<Recyclers> getBackRecyclersList(Recyclers recyclers) {
        recyclers.setStreetids(bsStreetDao.getStreetId(recyclers.getStreet()));
        List<Recyclers> list = recyclersDao.getBackRecyclersList(recyclers);
        for (Recyclers recyclers1 : list) {
            List<String> venuesNames = new ArrayList<>();
            String [] venuesIds = recyclers1.getBindingaddressids().split(",");
            for (String venuesId : venuesIds) {
                venuesNames.add(venuesDao.getVenuesName(venuesId));
            }
            recyclers1.setVenuesNames(venuesNames);
        }
        return list;
    }
}
